package com.itheima.hmshopping.app.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.hmshopping.app.util.GetPage;
import com.itheima.hmshopping.dubbo.api.SmsHomeRecommendProductServiceApi;
import com.itheima.hmshopping.entity.SmsHomeNewProduct;
import com.itheima.hmshopping.entity.SmsHomeRecommendProduct;
import com.itheima.hmshopping.util.HmPage;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SmsHomeRecommendProductService {

    @DubboReference
    private SmsHomeRecommendProductServiceApi smsHomeRecommendProductServiceApi;

    //添加首页推荐
    public void create(SmsHomeRecommendProduct smsHomeRecommendProduct) {
        smsHomeRecommendProductServiceApi.insert(smsHomeRecommendProduct);
    }

    //批量删除首页新品
    public void delete(List<Long> ids) {
        smsHomeRecommendProductServiceApi.delete(ids);
    }

    //分页查询首页新品
    public HmPage page(Integer pageNum, Integer pageSize, String productName, Integer recommendStatus) {
        Page<SmsHomeRecommendProduct> smsHomeRecommendProductPage=smsHomeRecommendProductServiceApi.page(pageNum,pageSize,productName,recommendStatus);
        HmPage page = GetPage.getPage(smsHomeRecommendProductPage, pageNum, pageSize);
        return page;
    }


    //批量修改首页新品状态
    public void recommendStatus(List<Long> ids, Integer recommendStatus) {
        smsHomeRecommendProductServiceApi.updateList(ids,recommendStatus);
    }

    //修改首页新品排序
    public void sort(Long id, Integer sort) {
        smsHomeRecommendProductServiceApi.updateSort(id,sort);
    }
}
